﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;

namespace DataLayer
{
    public class dlTasks
    {
        public DataSet TasksList(int userstoryid)
        {
            string connStr = ConfigurationManager.ConnectionStrings["constring"].ConnectionString;
            string querystring = @"select all TaskId, Titel, Description, Status, UserstoryId, EstimatedWorkload, RealWorkload, UserId, Comment from Tasks where (UserstoryID = '" + userstoryid + "')";

            SqlConnection connection = new SqlConnection(connStr);
            SqlCommand queryuserstory = new SqlCommand(querystring, connection);

            SqlDataAdapter myadapter = new SqlDataAdapter(queryuserstory);
            DataSet mydataset = new DataSet();

            myadapter.Fill(mydataset);

            return mydataset;
        }

        public DataSet TasksUser(int userid)
        {
            string connStr = ConfigurationManager.ConnectionStrings["constring"].ConnectionString;
            string querystring = @"select FirstName, Name from Users where (UserID = '" + userid + "')";

            SqlConnection connection = new SqlConnection(connStr);
            SqlCommand queryuser = new SqlCommand(querystring, connection);

            SqlDataAdapter myadapter = new SqlDataAdapter(queryuser);
            DataSet mydataset = new DataSet();

            myadapter.Fill(mydataset);

            return mydataset;
        }
    }
}
